﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

public delegate void ThreadExcuteDe();

public class ThreadExcute
{
    private static ThreadExcute instance;
    public static ThreadExcute Insatnce {
        get {
            if (instance == null) { instance = new ThreadExcute(); }
            return instance;
        }
    }

    private ThreadExcute() {
        e_wait = new Mutex();
    }

    public Mutex e_wait;
    public ThreadExcuteDe tde;

    public void Excute(ThreadExcuteDe d) {
        lock(instance){
            e_wait.WaitOne();
            d();
            e_wait.ReleaseMutex();
           
        }
    }


}
